package io.renren.modules.merchant.controller;

import io.renren.common.utils.R;
import io.renren.modules.merchant.entity.TurnoverVO;
import io.renren.modules.merchant.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("/report")
@Api(tags = "数据统计")
@Slf4j
public class ReportController {

    @Autowired
    private ReportService reportService;


    @GetMapping("/turnoverStatistics")
    @ApiOperation("营业额统计")
    public R turnoverStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
                                            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate){
        log.info("营业额统计开始:{}-{}",startDate,endDate);
        TurnoverVO turnoverVO = reportService.getTurnoverStatistics(startDate,endDate);
        return R.ok().put("turnover",turnoverVO);
    }
}
